package com.fire.center.service.impl;

import com.fire.center.domain.User;
import com.fire.center.mapper.UserMapper;
import com.fire.center.service.UserService;
import com.fire.common.domain.Result;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public List<User> findByConditions(User user) {
        return userMapper.findByConditions(user);
    }

    /*
    * 用户更新
    * */
    @Override
    public Result updateUser(User user) {
        int i= userMapper.updateUser(user);
        if(i>0){
            return Result.ok("更新成功");
        }
        return Result.err(501,"更新失败");

    }
    /*
    * 新增用户
    * */
    @Override
    public Result insertUser(User user) {
        int i= userMapper.insertUser(user);
        if(i>0){
            return Result.ok("添加成功");
        }
        return Result.err(501,"添加失败");
    }

    @Override
    public Result deleteUserById(String id) {
        int i= userMapper.deleteUserById(id);
        if(i>0){
            return Result.ok("删除成功");
        }
        return Result.err(501,"删除失败");
    }
}
